import React, { PureComponent } from 'react'
import Home from "./Home";
import Recommend from './Recommend';
import Profile from './Profile';
export class App extends PureComponent {
    constructor() {
        super()
        this.state ={
            message:"hello world",
            counter:0
        }
    }
    // shouldComponentUpdate(nextProps,newState){
    //     if(this.state.message !== newState.message || this.state.counter !== newState.counter){
    //         return true
    //     }
    //     return false

    // }
    changeText(){
        this.setState({
            message:"自是人生长恨水长东。 --相见欢·林花谢了春红"
        })
    }
    changeCount(){
        this.setState({
            counter: this.state.counter+1
        })
    }
  render() {
    console.log("App render")
    const { message, counter} = this.state
    return (
      <div>
        App-{message} - {counter}
        <button onClick={e=>this.changeText()}>修改文本</button>
        <button onClick={e=>this.changeCount()}>+1</button>
        <Home message={message}></Home>
        <Recommend counter={counter}></Recommend>
        <Profile message={message}></Profile>
      </div>
    )
  }
}

export default App